package com.imodia.checkoo.webtag;

import org.springframework.web.servlet.tags.RequestContextAwareTag;

import com.hsq.commons.util.BeanFactory;
import com.imodia.checkoo.bean.CmsArticleBean;
import com.imodia.checkoo.service.CmsArticleService;

public class ArticleTag extends RequestContextAwareTag  {
	private static final long serialVersionUID = -1764906844122921796L;
	private TldParam tldParam;

	public TldParam getTldParam() {
		return tldParam;
	}

	public void setTldParam(TldParam tldParam) {
		this.tldParam = tldParam;
	}

	@Override
	protected int doStartTagInternal() {
		CmsArticleService cmsArticleService = (CmsArticleService) BeanFactory.getBean("cmsArticleService");
		CmsArticleBean article = cmsArticleService.get(tldParam.getNewsId());
		if(article!=null){
//			article.setPageId(tldParam.getRedirectPageId());
//			String url = NewsContentUtil.getUrl(article.getContent(),"pageView.do", tldParam.getContentId(),tldParam.getNewsId(),article.getPageId(),1,article.getHtmlUrl());
//			pageContext.setAttribute("ArticleUrlTag", url);
//			article.setContent(NewsContentUtil.getContent(article.getContent(), tldParam.getContentId()));
			pageContext.setAttribute("ArticleTag", article);
		}
		return EVAL_BODY_INCLUDE;
	}

}
